<?php
$url = "http://localhost/mayphatdiengiare.vn/images/products/hello.jpg";

if(!preg_match('/(jpg|png|gif)$/',$url)){
    echo 'not'; 
}

$header_response = get_headers($url, 1);
if ( strpos( $header_response[0], "404" ) !== false )
{
  echo 'not';
} 
else 
{
  echo 'yes';
}
?>